﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using GoodsInvoicing.Views.View;
using GoodsInvoicing.Model.UserRole;
using Spring.Context;
using GoodsInvoicing.Presentions.Presenter;
using Spring.Context.Support;
using GoodsInvoicing.BLL.Service;

namespace GoodsInvoicing.Views.ViewImpl
{
    public partial class RoleListForm : Form, IRoleListForm
    {
        private IList<GI_Role> rolelist = null;
        private string searchRoleName = "";
        private int deleteRoleID = 0;

        private IApplicationContext applicationContext;
        private IRoleListFormPresenter presenter;

        public RoleListForm()
        {
            InitializeComponent();

            applicationContext = ContextRegistry.GetContext();
            presenter = new RoleListFormPresenter(this, applicationContext["GI_RoleService"] as IGI_RoleService);
            presenter.InitializeView();
        }

        #region IRoleListForm 成员
        public event EventHandler<EventArgs> RoleListFormLoad;

        public event EventHandler<EventArgs> SearchButtonClick;

        public event EventHandler<EventArgs> RoleDeleteClick;

        public IList<GI_Role> RoleList
        {
            get
            {
                return rolelist;
            }
            set
            {
                this.rolelist = value;
            }
        }

        public string SearchRoleName
        {
            get
            {
                return searchRoleName;
            }
            set
            {
                this.searchRoleName = value;
            }
        }

        public int DeleteRoleID
        {
            get
            {
                return deleteRoleID;
            }
            set
            {
                this.deleteRoleID = value;
            }
        }

        public void ShowRoleAddForm()
        {
            throw new NotImplementedException();
        }

        public void ShowRoleSaveForm()
        {
            throw new NotImplementedException();
        }
        #endregion

        private void RoleListForm_Load(object sender, EventArgs e)
        {
            if (this.RoleListFormLoad != null)
            {
                this.RoleListFormLoad(sender, e);

                this.bsRoleList.DataSource = this.RoleList;
            }
        }

    }
}
